<template>
  <Layer :layer="layer" @confirm="submit" @cancel="submit" ref="layerDom">
    <el-button v-if="!$store.state.user.is_teacher" size="default" type="primary" @click="handleJoinCourse">通过班号加入班课</el-button>
    <el-button size="default" type="primary" v-if="$store.state.user.is_teacher"
      @click="handleCreateCourse">新建班课</el-button>
    <el-button size="default" type="primary" v-if="false" @click="handleImportCourse">通过教学任务导入班课</el-button>
  </Layer>
</template>

<script lang="ts">
import { defineComponent, ref, reactive } from 'vue'
import Layer from '@/components/layer/index.vue'
import { ElMessage } from "element-plus";
import type { ElFormItemContext } from 'element-plus/lib/el-form/src/token'
import type { Ref } from 'vue'
import type { LayerType } from '@/components/layer/index.vue'

export default defineComponent({
  computed: {

  },
  components: {
    Layer
  },
  props: {
    layer: {
      type: Object,
      default: () => {
        return {
          show: false,
          title: '',
          showButton: true
        }
      }
    }
  },
  setup(props, ctx) {
    const ruleForm: Ref<ElFormItemContext | null> = ref(null)
    const layerDom: Ref<LayerType | null> = ref(null)


    init()
    function init() { // 用于判断新增还是编辑功能

    }
    return {

      ruleForm,
      layerDom,
    }
  },
  methods: {
    handleJoinCourse() {
      if (this.$store.state.user.is_teacher) {
        this.$router.push('/teacher/joinCourse')
      } else {
        this.$router.push('/student/joinCourse')
      }
      this.layer.show = false
    },
    handleCreateCourse() {
      this.$router.push('/teacher/createCourse')
      this.layer.show = false
    },
    handleImportCourse() {
      this.$router.push('/teacher/importCourse')
      this.layer.show = false
    },
    submit() {
      this.layer.show = false
    }
  }
})
</script>

<style lang="scss" scoped></style>